import QRequest from '@/service/index';
import { generateNameToLevel } from '@/config/constant';
import type { ProcedureParams, ProcedureResponse, ProcedureData } from './model/type';
import type { EquipmentParams, EquipmentResponse } from '@/api/modeling/equipment/model/type';

/**
 * @: 获取工序列表数据
 * @param {ProcedureParams} params
 * @return {*}
 */
export const doGetProcedureList = (params: ProcedureParams) => {
    return QRequest.get<ProcedureResponse>(`/working/procedure/page`, { params });
};

/**
 * @: 新增工序列表数据
 * @param {ProcedureData} data
 * @return {*}
 */
export const doAddProcedureList = (data: ProcedureData[]) => {
    return QRequest.post(`/working/procedure/save`, data, {
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @: 编辑工序列表数据
 * @param {ProcedureData} data
 * @return {*}
 */
export const doUpdateProcedureList = (data: ProcedureData) => {
    return QRequest.put(`/working/procedure/update`, data, {
        headers: {
            hideLoading: 1
        }
    });
};

/**
 * @: 获取工序列表详情数据
 * @param {string} id
 * @return {*}
 */
export const doGetProcedureDetail = (id: string) => {
    return QRequest.get(`/working/procedure/detail?id=${id}`, {
        headers: {
            loadingTarget: `#${generateNameToLevel('3')}`
        }
    });
};

/**
 * @: 删除工序列表
 * @param {number} data
 * @return {*}
 */
export const doDelProcedure = (data: number[]) => {
    return QRequest.delete(`/working/procedure/delete`, { data });
};

/**
 * @description: 工作设备列表
 * @param {EquipmentParams} params
 * @return {*}
 */
export const doGetEquipmentList = (params: EquipmentParams) => {
    return QRequest.get<EquipmentResponse>(`/equipment/page`, {
        params,
        headers: {
            loadingTarget: `#${generateNameToLevel('1')}`
        }
    });
};
